package cn.edu.gsau.info.service.impl;

import cn.edu.gsau.info.models.Jiaocaizhuanzhu;
import cn.edu.gsau.info.dao.JiaocaizhuanzhuDao;
import cn.edu.gsau.info.models.Shenhe;
import cn.edu.gsau.info.models.Zhengmingcailiao;
import cn.edu.gsau.info.myenum.ModuleIdClass;
import cn.edu.gsau.info.service.IJiaocaizhuanzhuService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jinjiang
 * @since 2022-11-17
 */
@Service
public class JiaocaizhuanzhuServiceImpl extends ServiceImpl<JiaocaizhuanzhuDao, Jiaocaizhuanzhu> implements IJiaocaizhuanzhuService {

    @Autowired
    JiaocaizhuanzhuDao jiaocaizhuanzhuDao;
    @Override
    public List<Jiaocaizhuanzhu> findByTianbaoId(Long tianbaoid) {

        return jiaocaizhuanzhuDao.findByTianbaoId(tianbaoid);
    }

    @Override
    public List<Zhengmingcailiao> findByModuleIdAndRecoreId(Integer moduleId, long recoreId) {

        return jiaocaizhuanzhuDao.findByModuleIdAndRecoreId(moduleId,recoreId);
    }

    @Override
    public List<Jiaocaizhuanzhu> findByTianbaoIdAndStatus(long tianbaoid, String status) {
        return jiaocaizhuanzhuDao.findByTianbaoIdAndStatus(tianbaoid,status);
    }

    @Override
    public List<Jiaocaizhuanzhu> findByTianbaoIdAndKeyWord(long tianbaoid, String keyword) {
        return jiaocaizhuanzhuDao.findByTianbaoIdAndKeyWord(tianbaoid,keyword);
    }

    @Override
    public List<Jiaocaizhuanzhu> findByTianbaoIdAndKeyWordAndStatus(long tianbaoid, String keyword, String status) {
        return jiaocaizhuanzhuDao.findByTianbaoIdAndKeyWordAndStatus(tianbaoid,keyword,status);
    }

    @Override
    public Boolean updateRecoreId(String fileName, long id) {
        return jiaocaizhuanzhuDao.updateRecoreId(fileName,id);
    }

    @Override
    public List<Zhengmingcailiao> findfileByrecoreIdAndModuleId(long recoreId, long moduleId) {
        return jiaocaizhuanzhuDao.findfileByrecoreIdAndModuleId(recoreId,moduleId);
    }

    @Override
    public IPage findByPage(long id, int pageIndex,int pagesize) {
        IPage<Jiaocaizhuanzhu> page = new Page<>(pageIndex,pagesize);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("tianbaoId",id);
        IPage iPage = jiaocaizhuanzhuDao.selectPage(page,queryWrapper);
        return iPage;
    }

    @Override
    public Boolean deleteCailiao(long id) {
        return jiaocaizhuanzhuDao.deleteCailiao(id);
    }

    @Override
    public Boolean addCailiao(long id, int moduleId, long recoreId, String fileName, String fileFullPath, String memo) {
        return jiaocaizhuanzhuDao.addCailiao(id, moduleId, recoreId, fileName, fileFullPath, memo);
    }

    @Override
    public List<Shenhe> findallshenhe(int moduleId, long tijiaoId) {
        return jiaocaizhuanzhuDao.findallshenhe(moduleId,tijiaoId);
    }

    @Override
    public List<Jiaocaizhuanzhu> findByNode(String node) {
        return jiaocaizhuanzhuDao.findByNode(node);
    }

    @Override
    public List<Jiaocaizhuanzhu> searchByNode(String keyword, String node) {
        return jiaocaizhuanzhuDao.searchByNode(keyword,node);
    }

    @Override
    public long findManagerId(long moduleId) {
        return jiaocaizhuanzhuDao.findManagerId(moduleId);
    }

    @Override
    public List<Shenhe> findShenhe(int moduleId, Long recoreId) {
        return jiaocaizhuanzhuDao.findShenhe(moduleId,recoreId);
    }

    @Override
    public boolean tijiaoShenhe(Shenhe shenhe, Long recoreId) {
        System.out.println(shenhe.getShenHeResult());
        System.out.println(shenhe.getShenHeTime());
        return jiaocaizhuanzhuDao.tijiaoShenhe(shenhe.getShenHeTime(),shenhe.getShenHeResult(),recoreId, ModuleIdClass.JIAOCAIYUZHUANZHU_id);
    }


}
